Skip to content

feat: Add opt-in subagent cost reporting - #194

Open
daanzu wants to merge 5 commits into
tintinweb:masterfrom
daanzu:cost-reporting
Open

feat: Add opt-in subagent cost reporting#194
daanzu wants to merge 5 commits into
tintinweb:masterfrom
daanzu:cost-reporting

Conversation

@daanzu

@daanzu daanzu commented Aug 1, 2026

Copy link
Copy Markdown

Summary

Adds opt-in, per-agent model cost reporting to pi-subagents.

  • Accumulates Pi-reported usage.cost.total across turns, resumes, and compaction.
  • Adds showCost, defaulting to false.
  • Reports costs in the live widget, foreground results, background notifications, get_subagent_result, and FleetView.
  • Preserves token and cost totals for finished turn-limited agents.
  • Adds an optional grouped notification summary, also disabled by default.

Related to #193. This change adds reporting in subagent surfaces; it does not add a top-level usage field to tool results for automatic parent-session footer aggregation.

Verification

  • npm run lint
  • npm run typecheck
  • npm run build
  • Focused cost-reporting tests: 232 passed
  • The full suite retains known Windows/path/timeout-related failures in this environment.
  • Manual user testing was light only; comprehensive live-provider testing was not performed.

Disclosure

This change was implemented with the assistance of an AI coding agent.

daanzu added 4 commits August 1, 2026 04:24
Accumulate Pi-reported usage.cost.total across subagent turns, resumes, and compaction without deriving cost from token totals.

Add the opt-in showCost setting and render estimated costs in the live widget, foreground and background results, and get_subagent_result. Keep cost reporting disabled by default and omit aggregate group totals.

Verification: npm run lint, npm run typecheck, npm run build, and the focused cost-reporting tests (232 passed).
Add a showGroupSummary setting for grouped background-agent notifications. When enabled, grouped results show aggregate completion and token usage above the individual agent entries, while existing output remains unchanged by default.

Include aggregate cost only when showCost is enabled, and cover settings persistence plus summary formatting with focused tests.
Expose the existing opt-in cost setting to FleetList and include each agent's reported lifetime cost in the right-aligned FleetView stats. Reuse retained lifetime usage so finished agents keep their cost, while preserving the existing output when cost display is disabled.

Add focused FleetView coverage for enabled and disabled cost display. Verified with the FleetView tests, lint, typecheck, and build.
Read lifetime token and reported cost totals from the completed agent record so turn-limited agents retain their usage counts after live activity state is removed. Keep cost visibility gated by the existing showCost setting.

Add regression coverage for steered agents, including the opt-in cost display behavior.

Verified with lint, typecheck, and the focused agent-widget tests (14 passed).
@daanzu

daanzu commented Aug 1, 2026

Copy link
Copy Markdown
Author

Rebased onto upstream master and resolved the conflicts. Lint, typecheck, and build pass; 821 tests pass, with 14 known Windows/path failures.

Pass the existing opt-in cost display setting into conversation viewers opened from FleetView and /agents. Read retained lifetime usage so completed agents keep showing their reported cost, and cover enabled and disabled display paths.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant